using System;
using Microsoft.Practices.ObjectBuilder2;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Microsoft.Practices.Unity.Interception
{
    [TestClass]
    public class MixedInterceptionInterceptionReflectorTest
    {
        [TestMethod]
        public void CanMixInterceptionTypes()
        {
            PolicyList policies = new PolicyList();

            InterceptionReflector.Reflect<IFoo, FooBar>(policies, new StubObjectFactory());

            NamedTypeBuildKey key = new NamedTypeBuildKey(typeof(FooBar));
            Assert.AreEqual(1, policies.Get<IVirtualInterceptionPolicy>(key).Count);
            Assert.AreEqual(1, policies.Get<IInterfaceInterceptionPolicy>(key).Count);
            Assert.AreEqual(1, policies.Get<IRemotingInterceptionPolicy>(key).Count);
        }

        public class FooBar : MarshalByRefObject, IFoo
        {
            [RemotingIntercept(typeof(RecordingHandler))]
            [VirtualIntercept(typeof(RecordingHandler))]
            [InterfaceIntercept(typeof(RecordingHandler))]
            public virtual void Foo() {}
        }

        public interface IFoo
        {
            void Foo();
        }
    }
}